<?php
namespace V1;

class WinningList extends \ResourceClass
{
    public function get(array $req, array $post, &$result)
    {
        if (!isset($req['t'])) {
            return '时间不能为空';
        }
        if (!isset($req['k'])) {
            return '公钥不能为空';
        }
        if (!isset($req['user_id'])) {
            return 'user_id不能为空';
        }
        try {
            $winning_list = new \Orm\WinningLog\WinningLogList();
            $winning_list['limit'] = isset($req['l']) ? $req['l'] : 20 ;
            $winning_list['offset'] = isset($req['o']) ? $req['o'] : 0 ;
            $winning_list['order'] = "`insert_time` desc";
            $winning_list['where'] = "`user_id` = {$req['user_id']}" AND "`is_del` = 0";
            $winning_list->load();
            $result = $winning_list['lists'];
        }catch (\Exception $e) {
            return $e->getMessage();
        }
    }
}